/**
 * 帖子流加载
 * @param el 元素id
 * @param post_url 数据列表请求url
 * @param total_url 数据总数请求url
 * @param id 请求参数可选
 * @param el2
 */
function load_posts(el,post_url,total_url,id,el2) {
    layui.use('flow', function() {
        let flow = layui.flow;
        flow.load({
            elem: el //指定列表容器
            ,done: function(m, next){ //到达临界点（默认滚动触发），触发下一页
                //让m=0
                m = 3*(m-1);
                let n = 3;
                let totalPage = 0;
                setTimeout(function(){
                    let lis = [];
                    let str = "";
                    $.get(post_url+'?m='+m+'&n='+n+'&id='+id, function(res){
                        //假设你的列表返回在data集合中
                        if(el2 !== undefined && id !== VISITORUID){
                            layui.each(res.data, function(index, item){
                                str='  <fieldset class="layui-elem-field layui-field-title">\n' +
                                    '                                <legend><span style="font-size: 10px">&nbsp;&nbsp;来自版块:<a onclick="skip_to(FORUM_INDEX,\'\')" href="javascript:void(0)")"  style="text-decoration: none"><b>'+item.forumname+'</b></a></span><span style="font-size: 10px">&nbsp;&nbsp;用户:<a onclick="skip_to(VISITOR_INDEX,'+item.uid+')" href="javascript:void(0)")"  style="text-decoration: none">'+item.nickname+'</a></span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-time"></i>'+item.createtime.substring(0,10)+'</span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-heart">&nbsp;&nbsp;'+item.likes+'人喜欢</i></span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-comment">&nbsp;&nbsp;'+item.cnums+'条评论</i></span></legend>\n' +
                                    '                                <div class="layui-field-box">\n' +
                                    '                               <h4 style="margin-left: 4%">'+item.title+' <a  onclick="skip_to(POST_INDEX,'+item.id+')" href="javascript:void(0)")" style="text-decoration: none"><i class="icon-circle-arrow-right"></i></a>&nbsp;&nbsp;<button class="btn btn-defalut btn-xs" id="'+item.id+'" onclick="lay_trash(this.id)">回收</button></h4></div>\n' +
                                    '                            </fieldset>';
                                lis.push(str);
                            });
                        }else {
                            layui.each(res.data, function(index, item){
                                str='  <fieldset class="layui-elem-field layui-field-title">\n' +
                                    '                                <legend><span style="font-size: 10px">&nbsp;&nbsp;来自版块:<a onclick="skip_to(FORUM_INDEX,\'\')" href="javascript:void(0)")" style="text-decoration: none"><b>'+item.forumname+'</b></a></span><span style="font-size: 10px">&nbsp;&nbsp;用户:<a onclick="skip_to(VISITOR_INDEX,'+item.uid+')" href="javascript:void(0)")" style="text-decoration: none">'+item.nickname+'</a></span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-time"></i>'+item.createtime.substring(0,10)+'</span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-heart">&nbsp;&nbsp;'+item.likes+'人喜欢</i></span><span style="font-size: 10px;color: grey">&nbsp;&nbsp;<i class="icon-comment">&nbsp;&nbsp;'+item.cnums+'条评论</i></span></legend>\n' +
                                    '                                <div class="layui-field-box">\n' +
                                    '                               <h4 style="margin-left: 4%">'+item.title+' <a onclick="skip_to(POST_INDEX,'+item.id+')" href="javascript:void(0)")" style="text-decoration: none"><i class="icon-circle-arrow-right"></i></a></h4></div>\n' +
                                    '                            </fieldset>';
                                lis.push(str);
                            });
                        }
                        //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
                        $.get(total_url+'?id='+id, function(res) {
                            //假设你的列表返回在data集合中
                            totalPage = res.data;
                            if(el2 !== undefined){
                                $(el2).html('('+res.data+')条');
                            }
                            //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
                            next(lis.join(''), m < totalPage);
                        });
                    });
                }, 500);
            }
        });
    });
}